package com.Lixiaoqian.Gulangyu.base

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.View
import com.Lixiaoqian.Gulangyu.R
import com.Lixiaoqian.Gulangyu.view.ToolTitleBar
import kotlinx.android.synthetic.main.layout_base.*

/**
 * Created by huangzhibo on 2018-02-26.
 * mail:1043202454@qq.com
 */
abstract class BaseActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        super.setContentView(R.layout.layout_base)
        initToolBar()
    }

    private fun initToolBar() {
        wd_toolbar.setCallClick(object : ToolTitleBar.ClickCall {
            override fun click(position: Int) {
                if (position == 0)
                    this@BaseActivity.finish()
                else
                    barRightEvent()
            }
        })
    }

    /**
     * bar 右上角点击回调
     */
    abstract fun barRightEvent()

    override fun setContentView(layoutResID: Int) {
        wd_rl_content.removeAllViews()
        View.inflate(this, layoutResID, wd_rl_content)
        onContentChanged()
    }
}